﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Forms;
using System.Drawing.Imaging;
using System.Drawing;
using System.Windows.Interop;
using WindowsInput;
using Microsoft.Win32;
using System.Diagnostics;
using HidDevice;
using WCintiqSettings.Pages;

using System.Runtime.InteropServices;


namespace WCintiqSettings.Pages
{

     //Need to have the Cintiq Handle syncronized!

     /// <summary>
     /// Interaction logic for Home.xaml
     /// </summary>
     public partial class Home : Page
     {
          

          Bitmap screenBMP = new Bitmap(Screen.PrimaryScreen.Bounds.Height, Screen.PrimaryScreen.Bounds.Width);
          Microsoft.Win32.RegistryKey rkLM = Registry.LocalMachine;
          RegistryKey TPCKey;
          Boolean PanAndScanEnabled;

          const string TPCKeyName = "20-\\\\?\\HID#VID_056A&PID_00CC&Col02#7&2dcf6d8d&3&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}";
          const string HPDisplayVal = "\\\\?\\DISPLAY#HWP2690#5&3710aa41&1&UID1048848#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}";
          const string WacomDisplayVal = "\\\\?\\DISPLAY#WAC1022#5&3710aa41&1&UID1048850#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}";
          const string TPCSubkey = "SOFTWARE\\Microsoft\\Wisp\\Pen\\Digimon";

          private WCintiqHID.Cintiq21UX wc21ux = new WCintiqHID.Cintiq21UX();
          private WCintiqSettings.ExpressKeySettings w21uxEKS = new WCintiqSettings.ExpressKeySettings();
          private System.Timers.Timer epTimer;
          private WCintiqHID.ScreenFactorClass mySF = new WCintiqHID.ScreenFactorClass();


          private static BitmapSource CopyScreen()
          {
               using (var screenBmp = new Bitmap(
                   (int)SystemParameters.VirtualScreenWidth,
                   (int)SystemParameters.VirtualScreenHeight,
                   System.Drawing.Imaging.PixelFormat.Format32bppArgb))
               {
                    using (var bmpGraphics = Graphics.FromImage(screenBmp))
                    {
                         bmpGraphics.CopyFromScreen((int)SystemParameters.VirtualScreenLeft, (int)SystemParameters.VirtualScreenTop, 0, 0, screenBmp.Size);
                         return Imaging.CreateBitmapSourceFromHBitmap(
                             screenBmp.GetHbitmap(),
                             IntPtr.Zero,
                             Int32Rect.Empty,
                             BitmapSizeOptions.FromEmptyOptions());
                    }
               }
          }

          private static BitmapSource CopyPrimaryScreen()
          {
               using (var screenBmp = new Bitmap(
                   (int)SystemParameters.PrimaryScreenWidth,
                   (int)SystemParameters.PrimaryScreenHeight,
                   System.Drawing.Imaging.PixelFormat.Format32bppArgb))
               {
                    using (var bmpGraphics = Graphics.FromImage(screenBmp))
                    {
                         bmpGraphics.CopyFromScreen(0, 0, 0, 0, screenBmp.Size);
                         return Imaging.CreateBitmapSourceFromHBitmap(
                             screenBmp.GetHbitmap(),
                             IntPtr.Zero,
                             Int32Rect.Empty,
                             BitmapSizeOptions.FromEmptyOptions());
                    }
               }
          }  

          public Home()
          {
               InitializeComponent();





               //myPASWindow.Owner = this;

			//ImgImage.BeginInit();
			//ImgImage.Source = CopyScreen();
			//ImgImage.EndInit();



          }

		private void Button_Click(object sender, RoutedEventArgs e)
		{

			

		}




     }
}
